﻿using System.Windows;
using System.Windows.Controls;

namespace CommonUtils.Test.Wpf
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Loaded += MainWindow_Loaded;

            TextBox2.TextChanged += TextBoxTest_TextChanged;
            TextBox2.SaveOnChange();
            TextBox2.Load();

            ButtonSetValue.Click += ButtonSetValue_Click;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            RegistryUtil.SetToConfig("test", "test");
            RegistryUtil.RemoveFromConfig("test");
        }

        private void TextBoxTest_TextChanged(object sender, TextChangedEventArgs e)
        {
            var textBox = sender as TextBox;
            TextBoxLog.Log("{0}检测到值变化为 {1}", textBox.Name, textBox.Text);
        }

        private void ButtonSetValue_Click(object sender, RoutedEventArgs e)
        {
            TextBox2.Text = TextBox1.Text;
        }
    }
}
